
/******************************************************************************************
* File Name  : ModbusRegister.h                                                            *
* Created   : 15/01/16                                                                    *
* Author   :                                                                              *
* Model   : JDKRC                                                                    *
* Description  :   ??????                                                           *
*******************************************************************************************/


/****************Include  Section  Begin***************************************************/



/****************Macro define  Section  Begin**********************************************/
/*
 * **********************************************************
 * Input Register Defines
 * **********************************************************
 */
//#include "stm32f10x.h"


#define	PARAM_INIT_FLAG_VALUE  0x995

#define	 REG_DI_CMPR_RUN_ST		0		//	ѹ��������
#define	 REG_DI_LO_PRESS_ST		1		//	��ѹ����
#define	 REG_DI_HI_PRESS_ST		2		//	��ѹ����
#define	 REG_DI_DEFROST_ST		3		//	��˪ģʽ  NC
#define	 REG_DI_REMOTE_ON_ST		4		//	Զ����ͣ
#define	 REG_TEMP_DISCHG		5		//	�����¶ȣ� Td  
#define	 REG_TEMP_SUCTION		6		//	�����¶ȣ� Ts
#define	 REG_TEMP_OUTDOOR		7		//	�����¶ȣ� To
#define	 REG_PRESS_SUCTION		8		//	��ѹѹ���� Ps
#define	 REG_PRESS_DISCHG		9		//	��ѹѹ���� Pd
#define	 REG_FAN_SP_1		10		//	����1����ͣ
#define	 REG_FAN_SP_2		11		//	����2����ͣ
#define	 REG_DO_CMPR_HTR		12		//	ѹ�������ȴ�����ͣ
#define	 REG_TO_EEV_SET		13		//	�������ͷ�����
#define	 REG_TEMP_EVAPORATION		14		//	�����¶ȣ� Te
#define	 REG_TEMP_CONDENSITION		15		//	�����¶ȣ� Tc
#define	 REG_TdSH		16		//	�������ȶȣ� TdSH
#define	 REG_TsSH		17		//	�������ȶȣ� TdSH
#define	 REG_AC_CURRENT		18		//	������1�β������NC
#define	 REG_DC_CURRENT		19		//	������2�β������
#define	 REG_CMPR_FRQ		20		//	ѹ����Ƶ��
#define	 REG_ERROR_CODE		21		//	���ϴ���
#define	 REG_ERROR_RECORD_1		22		//	
#define	 REG_ERROR_RECORD_2		23		//	
#define	 REG_ERROR_RECORD_3		24		//	
#define	 REG_ERROR_RECORD_4		25		//	
#define	 REG_ERROR_RECORD_5		26		//	
#define	 REG_ERROR_RECORD_6		27		//	
#define	 REG_ERROR_RECORD_7		28		//	
#define	 REG_ERROR_RECORD_8		29		//	
#define	 REG_ERROR_RECORD_9		30		//	
#define	 REG_ERROR_RECORD_10		31		//	
#define	 REG_ERROR_RECORD_11		32		//	
#define	 REG_ERROR_RECORD_12		33		//	
#define	 REG_ERROR_RECORD_13		34		//	
#define	 REG_ERROR_RECORD_14		35		//	
#define	 REG_ERROR_RECORD_15		36		//	
#define	 REG_ADC_P1		37		//	
#define	 REG_ADC_P2		38		//	
#define	 REG_ADC_P3		39		//	NC
#define	 REG_ADC_REF		40		//	
#define	 REG_TD_RPS		41		//	��תת��
#define	 REG_CURRENT		42		//	�����������巴��һ�β���� δ��2��//nc
#define	 REG_AC_VOLTAGE		43		//	������ѹ
#define	 REG_TD_DC_VOLTAGE		44		//	ֱ����ѹ
#define	 REG_TD_PHASE_CURRENT		45		//	������������巴������� δ��2��
#define	 REG_TD_IPM		46		//	IPM�¶�
#define	 REG_47		47		//	
#define	 REG_48		48		//	
#define	 REG_TD_FLAG		49		//	������־
#define	 REG_COMPRESSOR_STATE		50		//	����״̬
#define	 REG_REQUIRE_RPS		51		//	
#define	 REG_REQUIRE_ACC		52		//	NC
#define	 REG_PS_PD_RATE		53		//	
#define	 REG_PID_OUT		54		//	
#define	 REG_ERROR_CODE_1		55		//	
#define	 REG_ERROR_CODE_2		56		//	
#define	 REG_PFC_CODE_1		57		//	
#define	 REG_PFC_CODE_2		58		//	
#define	 REG_DO_FAN_SS_1		59		//	����1����ͣ nc
#define	 REG_DO_FAN_SS_2		60		//	����2����ͣ nc
#define	 REG_ERROR_RECORD_COUNT		61		//	
#define	 REG_CMPR_START		62		//	ѹ������ͣ����
#define	 REG_CMPR_WRITE		63		//	ѹ����д��ת��
#define	 REG_FAN1_WRITE		64		//	���1д��ת��
#define	 REG_FAN2_WRITE		65		//	���2д��ת��
#define	 REG_VALVE_1		66		//	
#define	 REG_VALVE_2		67		//	
#define	 REG_OILCOLLECT_STAGE		68		//	
#define	 REG_PID_TICK		69		//	
#define	 REG_PID_HZ		70		//	
#define	 REG_FCT_IN_DI		71		//	
#define	 REG_FCT_IN_FL		72		//	
#define	 REG_WAIT_START		73		//	
#define	 REG_WAIT_STOP		74		//	
#define	 REG_OC_STAGE		75		//	
#define	 REG_OC_WAIT_COUNT		76		//	
#define	 REG_OC_CANCEL_COUNT		77		//	
#define	 REG_OC_STAGE_DELAY		78		//	
#define	 REG_PROTECT_START		79		//	
#define	 REG_PROTECT_STOP		80		//	
#define	 REG_CMPR_TICK		81		//	
#define	 REG_FAN_TICK		82		//	
#define	 REG_CONTROL_STATE		83		//	
#define	 REG_CMPR_CMD		84		//	
#define	 REG_CMPR_DIRECT		85		//	
#define	 REG_86		86		//	
#define	 REG_87		87		//	
#define	 REG_FAN1_DUTYCYCLE		88		//	
#define	 REG_SOFT_VERSION		89		//
#define  REG_FAIL_RESTIME	90
#define  REG_EXV_STEP	91
#define  REG_EXV_ADJ	92
#define  REG_EXV_PULSE 93
#define  REG_FREQ_HOLD 94
#define  REG_POWERON_TIME 95
#define  REG_DRV_VERSION	96
#define  REG_FAN_FAULT_TIMS 97
#define  REG_ERROR_ORDER	98
#define  REG_START_FLAG	99

#define COOL 0
#define DEFROST_DELAY 1
#define DEFROST_ON 2
#define POST_WATER 3
#define NOT_COOL 4







/*
 * **********************************************************
 * Holding Register Defines
 * **********************************************************
 */
#define PARAMETER_DEFAULT_COUNT           113
#define PARAM_AMOUNT   113   //  

			//	��ַ	����
#define	HREG_TEMP_EVP_SETPT			0	//	�趨�����¶� Tset
#define	HREG_TEMP_DEADBAND_EVP			1	//	�����¶���ƫ�� deltaT
#define	HREG_TEMP_DEADBAND_DOWN			2	//	�����¶��趨��ƫ��
#define	HREG_PS_CMPR_STOP 			3	//	ѹ����ֹͣ, ����ѹ���������� ��ѹͣ���͵�ѹ����
#define	HREG_CMPR_FRQ_INIT 			4	//	ѹ������ʼת��
#define	HREG_CMPR_FRQ_MIN 			5	//	ѹ����������Сת��
#define	HREG_CMPR_FRQ_MAX 			6	//	ѹ�����������ת��
#define	HREG_CMPR_INIT_TIME 			7	//	��ʼ��ʱ�䣬30s
#define	HREG_START_DELAY 			8	//	����ǰ��ʱ
#define	HREG_WAITSTOP_DELAY			9	//	��СƵ��ͣ����ʱ
#define	HREG_PS_LO_STOP_DL 			10	//	����ѹ����ͣ����ʱ
#define	HREG_INCR_TERM 			11	//	����ʱ��Ƶ��������
#define	HREG_SLOW_INCR_TERM			12	//	������Ƶ��������
#define	HREG_DESC_TERM			13	//	����ʱ��Ƶ��������
#define	HREG_FAST_DESC_TERM			14	//	���ټ�Ƶ��������
#define	HREG_FORCE_DECREASE_BUTTOM			15	//	ǿ�Ƽ�ƵƵ������
#define	HREG_FAN_START_T 			16	//	��������¶�
#define	HREG_FAN_DEADZONE  			17	//	���������ƫ������¶ȣ�
#define	HREG_PD_PS_N1			18	//	Pd/Ps < N1, ����5���ӣ�����Ƶ�ʣ�3Hz/s, 1λС��
#define	HREG_PD_PS_N2 			19	//	N1<= Pd/Ps < N2, ����Ƶ�ʣ���ֹƵ�ʼ��٣� 1λС��//  N2 <= Pd/Ps��Ƶ���������ƣ� 1λС��
#define	HREG_PD_HIGH_STOP			20	//	����ѹ����ǿ��ͣ��, 1λС��
#define	HREG_PD_HIGH_UL			21	//	����ѹ����ǿ�ƽ�Ƶ��1λС��
#define	HREG_PD_HIGH_NI			22	//	����ѹ���߽�ֹ��Ƶ��1λС��
#define	HREG_PD_HIGH_SL			23	//	����ѹ����������Ƶ��1λС��
#define	HREG_AC_HIGH_STOP 			24	//	1�β������ǿ��ͣ��������
#define	HREG_AC_HIGH_UL			25	//	1�β������ǿ�ƽ�Ƶ������
#define	HREG_AC_HIGH_NI			26	//	1�β�����߽�ֹ��Ƶ������
#define	HREG_AC_HIGH_SL			27	//	1�β������������Ƶ������
#define	HREG_DC_HIGH_STOP 	28	//	2�β������ǿ��ͣ����1λС��
#define	HREG_DC_HIGH_UL			29	//	2�β������ǿ�ƽ�Ƶ��1λС��
#define	HREG_DC_HIGH_NI			30	//	2�β�����߽�ֹ��Ƶ��1λС��
#define	HREG_DC_HIGH_SL			31	//	2�β������������Ƶ��1λС��
#define	HREG_TD_HIGH_STOP  	32	//	�����¶ȸ�ǿ��ͣ��������
#define	HREG_TD_HIGH_UL			33	//	�����¶ȸ�ǿ�ƽ�Ƶ������
#define	HREG_TD_HIGH_NI			34	//	�����¶ȸ߽�ֹ��Ƶ������
#define	HREG_TD_HIGH_SL  			35	//	�����¶ȸ�������Ƶ������
#define	HREG_IPM_HIGH_STOP 			36	//	IPM�¶ȸ�ǿ��ͣ��������
#define	HREG_IPM_HIGH_UL 			37	//	IPM�¶ȸ�ǿ�ƽ�Ƶ������
#define	HREG_IPM_HIGH_NI			38	//	IPM�¶ȸ߽�ֹ��Ƶ������
#define	HREG_IPM_HIGH_SL			39	//	IPM�¶ȸ�������Ƶ������
#define	HREG_PS_LO_STOP			40	//	����ѹ����ǿ��ͣ����1λС��
#define	HREG_START_INTERVAL			41	//	������С�������
#define	HREG_NEXT_START_DELAY			42	//	ͣ������ʱ����  
#define	HREG_TD_LOW_AL			43	//	�����¶ȵͱ���
#define	HREG_TD_LOW_DL 			44	//	�����¶ȵͱ�����ʱ // �����¶ȵͣ�Ĭ��300��
#define	HREG_PS_HIGH_AL			45	//	����ѹ���߱���// ����ѹ���ߣ�����ʱ��0.5-15bar��Ĭ��5.8Bar����ʱ20min
#define	HREG_PS_HIGH_DL			46	//	����ѹ���߱�����ʱ������0.1����
#define	HREG_OIL_COL_WT_FQ 			47	//	�Զ����ʹ���Ƶ��
#define	HREG_OIL_COL_WT_M			48	//	�Զ����ʹ���ʱ�䣬����
#define	HREG_OIL_COL_OP_S			49	//	�Զ����Ͷ���ʱ��
#define	HREG_OIL_COL_OP_FQ			50	//	�Զ����Ͷ���Ƶ��
#define	HREG_OIL_COL_RE_S			51	//	���͸����趨Ƶ�ʳ�����������ȡ��ʱ���ۼ�
#define	HREG_OIL_COL_RE_HZ			52	//	���͸��ڴ�Ƶ�ʳ����趨������ȡ��ʱ���ۼ�
#define	HREG_TEST_FLAG			53	//	����ģʽ
#define	HREG_TEST_SPEED			54	//	����ѹ����ת��
#define	HREG_TEST_FAN1_SPEED 			55	//	���Է��1ת��
#define	HREG_TEST_FAN2_SPEED			56	//	���Է��2ת��
#define	HREG_CMPR_PID_EN			57	//	ѹ����PID�㷨ʹ��
#define	HREG_CMPR_PID_P			58	//	ѹ����PID��Pֵ
#define	HREG_CMPR_PID_I			59	//	ѹ����PID��Iֵ
#define	HREG_CMPR_PID_D			60	//	ѹ����PID��Dֵ
#define	HREG_CMPR_PID_DELAY			61	//	ѹ����PID�ļ�������
#define	HREG_VALVE_ON_TD			62	//	��Һ�������¶ȣ�����
#define	HREG_PFC_AMP			63	//	��Ƶ��PFCд�����
#define	HREG_ACC_IN_TRANSDUCER			64	//	��Ƶ������ƵĬ������
#define	HREG_TRANS_AVOID_BUTTOM			65	//	����Ƶ�����ֵ
#define	HREG_TRANS_AVOID_WIDE			66	//	����Ƶ�ο���
#define	HREG_WINTER_MODE			67	//	����ģʽ�趨
#define	HREG_WINTER_OUTDOOR_TEMP_SEPT			68	//	����ģʽ�¶��趨
#define	HREG_WINTER_OUTDOOR_TEMP_DIFF			69	//	����ģʽ�¶��趨ƫ��
#define	HREG_WINTER_DELAY			70	//	����ģʽ��ʱ
#define	HREG_WINTER_EVP_SETPT_DIFF			71	//	����ģʽ�����¶��趨ƫ��
#define	HREG_WINTER_PS_CMPR_STOP_DIFF			72	//	����ģʽѹ����ͣ��ƫ��
#define	HREG_BAUD 								73	//	0��9600��1��19200��2��57600��3��115200
#define	HREG_PARITY 							74	//	У��λ
#define	HREG_STOP_BIT							75	//	ֹͣλ
#define	HREG_DEVICE_ID						76	//	������ַ
#define	HREG_FQ_WAIT_SETP					77	//	Ƶ�ʵ��ڵȴ����� // ����ѹ���ͣ�ͣ��Ҳ��飬�ж���ýй¶��ֻ������0.5bar
#define	HREG_FQ_WAIT_SEC					78	//	Ƶ�ʵ��ڵȴ�����
#define	HREG_FAN_PID_P						79	//	���PID��Pֵ
#define	HREG_FAN_PID_I						80	//	���PID��Iֵ
#define	HREG_FAN_PID_D						81	//	���PID��Dֵ
#define	HREG_FAN_PID_DELAY				82	//	���PID�ļ�������
#define	HREG_FAN_FRQ_MIN					83	//	�����СƵ��,10rpm
#define	HREG_FAN_FRQ_MAX					84	//	������Ƶ��,10rpm
#define	HREG_JETLIQ_START_TD			85	//
#define HREG_JETLIQ_START_FREQ		86	//
#define	HREG_JETLIQ_COND_TIM			87	//	
#define	HREG_JETLIQ_STOP_TD				88	//	
#define	HREG_JETLIQ_USTP_OPEN			89	//
#define HREG_JETLIQ_LSTP_OPEN			90
#define	HREG_JETLIQ_BDCR_DEV			91	//	
#define	HREG_JETLIQ_3STP_OPEN			92	//	
#define	HREG_JETLIQ_2STP_OPEN			93	//	
#define	HREG_JETLIQ_1STP_OPEN			94	//	
#define	HREG_JETLIQ_0STP_OPEN			95
#define	HREG_SET_DEFAULT					96	//	
#define	HREG_FACTORY_TEST_FLAG		97	//
#define	HREG_COMPRESSOR_POWER			98	//
#define	HREG_VAR_DISP_MAX					99	//
#define HREG_TRANS_AVOID_P1				100
#define HREG_TRANS_AVOID_P2				101
#define HREG_TRANS_AVOID_P3				102
#define HREG_TRANS_AVOID_P4				103
#define HREG_TRANS_AVOID_P5				104
#define HREG_ELV_STEP							105
#define HREG_FREQ_STEP1						106
#define HREG_FREQ_STEP2						107
#define HREG_FREQ_STEP3						108
#define HREG_FREQ_HDTIME					109
#define HREG_OVLD_FREQ						110
#define HREG_HEATE_TEMP						111
#define HREG_HEATE_TIME						112

#define IR_VAR_DISP_MAX  					100
#define HR_VAR_DISP_MAX  					113


#define PASSWORD_LENTH            6   
#define PASSWORD_AMONT            6  
#define PASSWORD_AMONT2           2

#define EE_DDFROST_MONTH_VALUE  	0x320    //400
#define EE_DDFROST_DATE_VALUE  		0x322
#define EE_DDFROST_TIME_VALUE  		0x324

#define EE_DDFROST_RUN_TIME_VALUE  0x326    

//���ڴ洢��������

#define EE_ALARM_RECORD1_ADDR   0x32a
#define EE_ALARM_RECORD1_DAY    0x32c
#define EE_ALARM_RECORD1_TIME   0x32e

#define EE_ALARM_RECORD2_ADDR   0x330
#define EE_ALARM_RECORD2_DAY    0x332
#define EE_ALARM_RECORD2_TIME   0x334

#define EE_ALARM_RECORD3_ADDR   0x336
#define EE_ALARM_RECORD3_DAY    0x338
#define EE_ALARM_RECORD3_TIME   0x33a

#define EE_ALARM_RECORD4_ADDR   0x33c
#define EE_ALARM_RECORD4_DAY   0x33e
#define EE_ALARM_RECORD4_TIME   0x340

#define EE_ALARM_RECORD5_ADDR   0x342
#define EE_ALARM_RECORD5_DAY   0x344
#define EE_ALARM_RECORD5_TIME   0x346

#define EE_ALARM_RECORD6_ADDR   0x348
#define EE_ALARM_RECORD6_DAY   0x34a
#define EE_ALARM_RECORD6_TIME   0x34c

#define EE_ALARM_RECORD7_ADDR   0x34e
#define EE_ALARM_RECORD7_DAY   0x350
#define EE_ALARM_RECORD7_TIME   0x352

#define EE_ALARM_RECORD8_ADDR   0x354
#define EE_ALARM_RECORD8_DAY   0x356
#define EE_ALARM_RECORD8_TIME   0x358

#define EE_ALARM_RECORD9_ADDR   0x35a
#define EE_ALARM_RECORD9_DAY   0x35c
#define EE_ALARM_RECORD9_TIME   0x35e

#define EE_ALARM_RECORD10_ADDR   0x360
#define EE_ALARM_RECORD10_DAY   0x362
#define EE_ALARM_RECORD10_TIME   0x364

#define EE_ALARM_RECORD_LOCATION   0x366



#define		REG_VRms_U_LOW	2016	//		��ѹͨ������Чֵ
#define		REG_VRms_U_Hi	2017	//		��ѹͨ������Чֵ

#define		REG_IRms_I_LOW	2012	//		��ѹͨ������Чֵ
#define		REG_IRms_I_Hi	2013	//		��ѹͨ������Чֵ                 

#define		REG_FRms_F_LOW	2018	//		��ѹͨ������Чֵ
#define		REG_FRms_F_Hi	2019	//		��ѹͨ������Чֵ  


#define		REG_PRms_P_LOW	2020	//		��ѹͨ������Чֵ
#define		REG_PRms_P_Hi	2021	//		��ѹͨ������Чֵ  



#define		REG_WRms_W_LOW	2026	//		��ѹͨ������Чֵ
#define		REG_WRms_W_Hi	2027	//		��ѹͨ������Чֵ 




#define		GP1 	0	//	
#define		GQ1 	1	//	
#define		GS1 	2	//	
#define		HFConst 3

#define		P1OFFSETH 4
#define		GPhs1     5
#define		P1OFFSETL 6

#define		ADCCON    7


#define		UrmsGain 10
#define		IrmsGain 11
#define		PrmsGain 12

#define		PULSEConst 13


#define		EE_W_L    14
#define		EE_W_H    15

#define	    VRms   0 //��ѹ��Чֵ

#define		UrmsGainB 6
#define		IrmsGainB 7
#define		PrmsGainB 8
#define		PULSEConstB 9
#define		GCH        10

#define Alarm_Param_NOT_USED  0xffff

extern u8 passwordCounts;

extern u16 ClearnBeforEnergyReadValues[2];
extern void SetRegistReadFlag(u8 channel);
extern u8 GetRegistReadFlag(void);
extern u8 IGet_Controller_States(void);
extern  u8	Params_Init_By_Stored(void	);
extern void SetParamValue( u16 Address ,s16 Value);
extern void Params_Set_dafault(void);

extern  u8 SetJDKRCParamValue( u16 location  , s16 value );
extern  s16 GetJDKRCParamValue( u16 Address );
extern  s16	Param_Get_MAX(	u16	index	);
extern  s16	Param_Get_MIN(	u16	index	);
extern s16 GetOtherParamValue( u16 Address );
extern s16 GetJDASDParamValue( u16 Address );
extern u8 SetOtherParamValue( u16 Address    ,   s16 Value   );
extern u8 GetParamDec(u16 index);
extern void SetParamValue( u16 Address ,s16 Value);
u8 GetDefaultSet(s16 Controller1, s16 Controller2);


extern u8  Master_Station_Init(    void    );
extern u16 GetATT7059SReadValue(u8 address);
extern u16 GetATT7059SReadWValue(u8 address);
extern  s16 GetJDKRCStatuesValue(u16 address);
extern u16 GetEnergyReadValues(u8 address);
extern u8 EnergyP_Cali_Service(void);

extern  u16 Get_ModbusSlaveData(u8 i);


extern int16_t	Param_Get_Delta(	u16	index	);
extern int16_t	Param_Get_Decimal(	u16	index	);

